# Definition for singly-linked list.
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution:
    def middleNode(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        list = []
        p = head
        while p!=None:
            list.append(p)
            p = p.next
        if len(list)==0:
            return None
        return list[len(list)//2]


def main():
    sol = Solution()
    print(sol.middleNode())
    
if __name__=="__main__":
    main()